import "./../sass/login.scss";
import "./../sass/reset.scss";
import $ from "jquery";
import $fn from "./login-fn"
const layer = require("layui-layer");



$(function () {
    
    $("#loginform").submit(function () {

        //发送数据到后台

        $.ajax({
            url: "http://10.41.151.55:8081/api/login",
            data: $("#loginform").serialize(),
            type: "post",
            dataType: "json"
        }).then(function (res) {
            console.log(res)
            layer.msg(res.msg, { icon: res.status == 200 ? 1 : 2 });
            //登录成功后,把当前登陆者的信息保存到 localStorage
            // localStorage 存储本地,5m,不手动清除,就永久存在
            if (res.status == 200) {
                localStorage.setItem("tencent", JSON.stringify(res.data[0]));
                
                setTimeout(function(){ 
                    window.location.href = 'http://localhost:8080/index.html' 
                }, 1500);
            }
        })
        return false;
    })

})




$(function () {
    $fn.banner()
})